void drawDancer(pt P, float w, Boolean r) { // shows dancer in 2D at P with orientation w standing on right foot when r
  pushMatrix();
  translate(P.x, P.y);
  rotate(w);
  pushMatrix(); 
  scale(.4, 1); 
  ellipse(0, 0, 100, 100); 
  popMatrix();
  ellipse(0, 0, 20, 20); // supporting foot
  pushMatrix(); 
  if (r) translate(0, 30); 
  else translate(0, -30); 
  scale(.2, .2); 
  ellipse(0, 0, 100, 100); 
  popMatrix(); // other foot
  pushMatrix(); 
  translate(5, 0); 
  scale(.45, .35); 
  ellipse(0, 0, 100, 100); 
  popMatrix(); // head
  popMatrix();
}

void drawDancer3D(pt P, float w, Boolean r) { // shows dancer in 3D at P with orientation w standing on right foot when r
  pushMatrix();
  translate(P.x, P.y, 50); 
  rotate(w); // align body
  pushMatrix(); 
  scale(.4, .6, 1); 
  sphere(50); 
  popMatrix(); // body
  pushMatrix(); 
  translate(0, 0, -100); 
  scale(.25, .1, .1); 
  sphere(50); 
  popMatrix(); // supporting foot
  pushMatrix(); 
  int rfootx;
  int rfooty;
  int rfootz;
  int lfootx;
  int lfooty;
  int lfootz;
  if (r){ //set up variables for drawing legs
    rfootx = 0;
    rfooty = 30;
    rfootz = -100;
    lfootx = 0;
    lfooty = 0;
    lfootz = -100;
    translate(rfootx, rfooty, rfootz); 
  }
  else{
    rfootx = 0;
    rfooty = 0;
    rfootz = -100;
    lfootx = 0;
    lfooty = -30;
    lfootz = -100;
    translate(lfootx,lfooty, lfootz);
  } 
  scale(.25, .1, .1); 
  sphere(50); 
  popMatrix(); // other foot
  pushMatrix(); 
  translate(10, 0, 65); 
  scale(.35, .35, .50);  
  sphere(50);  
  popMatrix(); // head
  
  pushMatrix();
  translate(0,-25,-20);
  scale(.2, .2, .2);
  sphere(50);
  popMatrix(); //left hip
  
  pushMatrix();
  translate(0,25,-20);
  scale(.2, .2, .2);
  sphere(50);
  popMatrix(); //right hip
  
  pushMatrix();
  float distancex = rfootx; //find the distance from the hip to the supporting foot
  float distancey = rfooty-25;
  float distancez = rfootz + 20;
  translate(0,25,-20);
  for(int i = 0; i < 10; i++){
    pushMatrix();
    translate(rfootx-distancex*i/10,(rfooty-25)-distancey*i/10,(rfootz+20)-distancez*i/10);
    sphere(5); //draw 10 spheres along the distance from the hip to the foot
    popMatrix();
  }
  popMatrix();
  
  pushMatrix(); //find the distance from the hip to the other foot
  distancex = lfootx;
  distancey = lfooty+25;
  distancez = lfootz + 20;
  translate(0,-25,-20);
  for(int i = 0; i < 10; i++){
    pushMatrix();
    translate(lfootx-distancex*i/10,(lfooty+25)-distancey*i/10,(lfootz+20)-distancez*i/10);
    sphere(5);
    popMatrix();
  }
  popMatrix();
  
  popMatrix();
}


